<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Controller extends CI_Controller
{
    public function __construct()
	{
        parent::__construct();
		$member = $this->session->userdata('user');
		$this->memberid=$member['userid'];
		$this->cartdetails=$this->cart->contents();
		$this->activemenu='';
		if($this->general_model->loggedin("user") == TRUE)
		{
			$storecart=$this->general_model->select_val('speedhost_member','cart','userid = '.$this->memberid);
			if($storecart['cart']=='')
			{
				
				$updatecart=array("cart"=>serialize($this->cartdetails));
				$this->general_model->update("speedhost_member",$updatecart,"userid = ".$this->memberid);
				
			}
			else
			{
				$pcart=unserialize($storecart['cart']);
				
				$newcart=array_merge($pcart,$this->cartdetails);
				$this->cart->insert($newcart);
				$updatecart=array("cart"=>serialize($newcart));
				$this->general_model->update("speedhost_member",$updatecart,"userid = ".$this->memberid);
				
			}
			$this->cartdetails=$this->cart->contents();
		}
		
    }
	
}